import requests
def miningMachine(host,port):
    while True:
        response = requests.get(f'http://{host}:{port}/mine')
        if response.status_code == 200:
            # length = response.json()['length']
            info = response.json()
            print("又挖到了一个Bit Coin")
            print("info" + str(info))
if __name__ == '__main__':
    from argparse import ArgumentParser

    parser = ArgumentParser()
    parser.add_argument('-i', '--host', default="127.0.0.1", type=str, help='host to mining')
    parser.add_argument('-p', '--port', default=5000, type=int, help='port to mining')
    args = parser.parse_args()
    host = args.host
    port = args.port
    miningMachine(host, port)
